import { h } from 'preact';

// TODO: 默认样式引入

export function Rect(props) {
  const attrs = {
    // default
    x: 0,
    y: 0,
    width: 10,
    height: 10,
    fill: 'transparent',
    fillOpacity: 1,
    strokeWidth: '1px',
    stroke: '#000',
    strokeOpacity: 1,
    ...props,
  };

  return (
    <rect {...attrs} />
  );
}

export function getRectAnchors(props) {
  const { x, y, width, height } = props;

  return [
    { x: x + width / 2, y: y },
    { x: x + width, y: y + height / 2 },
    { x: x + width / 2, y: y + height },
    { x: x, y: y + height / 2 }
  ]
}
